#ifndef __ONLINE_WEBPAGE_H__
#define __ONLINE_WEBPAGE_H__
#include "../../../libs/SplitTool.hpp"
#include "../../../log/Mylog.h"
#include <string>
#include <vector>
#include <map>
#include <set>
using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

namespace SE
{
    class Online_WebPage
    {
    public:
        const static size_t TOPK_NUMBER = 20;
        Online_WebPage(const string &doc, SplitTool &splitTool, set<string>& stopWords);
        map<string, int> &getWordsMap();
        void makeSummary(const map<string,int>& wordsMap); //根据查询词生成摘要 
        string getDoc() const;
        string getTitle() const { return _title;}
        string getLink() const { return _link; }
        string getSummary() const { return _summary;}

        //判断两篇文章是否相等
        friend bool operator==(const Online_WebPage &lhs, const Online_WebPage &rhs);

    private:
        void processDoc();                   
        void storeWordsMap(const string &s); //词频统计
        void calcTopK(size_t k);             //topK算法计算频率最高的k个单词

    private:
        string _doc; 
        string _title;
        string _link; 
        string _description;
        string _content;
        string _summary;
        vector<string> _topWords;   //该篇文章频率最高的前K个词
        map<string, int> _wordsMap; //高频词表<单词，频率>
        SplitTool &_splitTool;      //cppjieba中文分词库
        set<string> &_stopWords;    //停词库   
    };
}

#endif